home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************************
- *
- *
- * ObjectMacZapp -- a standard Mac OOP application template
- *
- *
- *
- * ZFolderScanner.h -- a generic object for recursively searching folders
- *
- *
- *
- *
- *
- * © 1996, Graham Cox
- *
- *
- *
- *
- *************************************************************************************************/
-
-
- #pragma once
-
- #ifndef __ZFOLDERSCANNER__
- #define __ZFOLDERSCANNER__
-
- #ifndef __ZFILE__
- #include "ZFile.h"
- #endif
-
- class ZProgress;
-
-
- class ZFolderScanner : public ZFile
- {
- protected:
- short curDepth;
- short searchDepth;
- long topDirID;
- Boolean useProgressDialog;
- ZProgress* itsPD;
- CInfoPBRec pb;
- Str31 fName;
-
- public:
- ZFolderScanner( const FSSpec& rootFolder );
- ZFolderScanner();
-
- ~ZFolderScanner();
-
- virtual void SetSearchDepth( const short aSearchDepth );
- virtual Boolean PickFolder();
-
- virtual void ScanFolder();
-
- protected:
- virtual void Scan1Folder( const long dirID );
- virtual void Process1File( const FSSpec& aSpec, const OSType fType );
- virtual void Process1Folder( const FSSpec& aSpec );
- };
-
-
-
- typedef struct
- {
- StandardFileReply aReply;
- Boolean selectHit;
- Boolean dirFlag;
- }
- tFolderInfo;
-
-
-
- pascal OSErr GetDirectoryID(short vRefNum,
- long dirID,
- StringPtr name,
- long *theDirID,
- Boolean *isDirectory);
-
- pascal OSErr FSpGetDirectoryID(const FSSpec *spec,
- long *theDirID,
- Boolean *isDirectory);
-
- Boolean ChooseFolder(FSSpec* folderSpec);
- Boolean GetFullPathname(FSSpec* aSpec, Str255 pathname);
- OSErr MakeCanonFSSpec ( FSSpec *spec );
- Boolean SameFile ( FSSpec *spec1, FSSpec *spec2 );
-
-
- static pascal Boolean GetDirFileFilter(ParmBlkPtr pb, tFolderInfo* fInfo);
- static pascal short GetDirDlgHook(short item, DialogPtr theDialog, tFolderInfo* fInfo);
- static void SetSFButtonTitle(ControlHandle theButton, FSSpec* theFile, Rect* buttonRect);
- static short GetSFCurVol();
- static long GetSFCurDir();
- static void pStrInsert(StringPtr dest, StringPtr src);
-
-
-
-
-
-
-
-
-
- /*
-
- This object is useful for doing general recursive searches through a hierarchy of folders. For
- each file it encounters, it calls Process1File with the file spec. You can override this
- method to do whatever you want with the file. If another folder is encountered, it calls
- Scan1Folder recursively to the maximum depth you set with SetSearchDepth(). By default this is
- 0, so it only searches the first folder. Pass -1 to search all folders below the first folder
- as well. If you want to search the entire hard disk, pass the FSSpec of the hard disk in the
- constructor, or use the default constructor to search the startup disk.
-
- To kick off a search, simply call ScanFolder().
-
- To provide a user-interface for selecting a folder, call PickFolder(). This presents a custom
- Standard File dialog to pick a folder, which then becomes the current folder. You can then call
- ScanFolder to search it.
-
- Sincethis inherits from ZFile, you can call GetFSSpec, etc. However, it is meaningless to try to
- call Open, etc. on this object, since the spec should be for a folder.
-
- */
-
-
-
- #define kDefaultSearchDepth 0
- #define kPickFolderDialogID 8001
- #define kPickFolderButton 13
- #define kStdButtonTextStrID 128
-
- #endif